package org.db2.project.airline.dao.impl;

import org.db2.project.airline.dao.ClientDAO;
import org.db2.project.airline.dao.DAOException;
import org.db2.project.airline.model.Client;
import org.hibernate.HibernateException;

/**
 *
 */
public class HibernateClientDAO extends HibernateGenericDAO<Client> implements ClientDAO {

    public HibernateClientDAO() {
        // empty constructor
    }

    @Override
    public Client findByEmail(String email) throws DAOException {
        try {
            return (Client) getSession().createQuery("from Client where email = :email")
                    .setParameter("email", email).uniqueResult();
        } catch (HibernateException e) {

            throw new DAOException("Error occurred when retrieving entity from persistence.", e);
        }
    }
}
